package com.jic.order.impl;

import java.lang.Long;
import java.util.List;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.order.entity.OrderAutomaticComplete;
import com.jic.order.mapper.OrderAutomaticCompleteMapper;
import com.jic.order.service.OrderAutomaticCompleteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 订单自动完成表
 * @author : 
 * @email : 
 * @since : 2020-03-02 01:20:07
 * @version : v1.0.0
 */
@Service
public class OrderAutomaticCompleteServiceImpl implements OrderAutomaticCompleteService {

    @Autowired
    private OrderAutomaticCompleteMapper orderAutomaticCompleteMapper;

    @Override
    public long insert(OrderAutomaticComplete orderAutomaticComplete) {
        long flag = orderAutomaticCompleteMapper.insert(orderAutomaticComplete);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return orderAutomaticCompleteMapper.delete(id);
    }

    @Override
    public long update(OrderAutomaticComplete orderAutomaticComplete) {
        return orderAutomaticCompleteMapper.update(orderAutomaticComplete);
    }

    @Override
    public OrderAutomaticComplete queryByPrimaryKey(Long id){
        return orderAutomaticCompleteMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<OrderAutomaticComplete> query(OrderAutomaticComplete orderAutomaticComplete){
        return orderAutomaticCompleteMapper.query(orderAutomaticComplete);
    }

    @Override
    public PageResult<OrderAutomaticComplete> queryPage(OrderAutomaticComplete orderAutomaticComplete, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<OrderAutomaticComplete> list = orderAutomaticCompleteMapper.queryPage(startIndex, pageQuery.getLimit(), orderAutomaticComplete);
        long count = orderAutomaticCompleteMapper.queryPageCount(orderAutomaticComplete);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}